package javamobile.controller;

import java.util.HashMap;
import java.util.Map;

public abstract class Action {
    public abstract String getName();

    public abstract Map<String, Object> perform(Map<String, Object> input);

    private static Map<String,Action> hash = new HashMap<String,Action>();

    public static void add(Action a) {
    	synchronized (hash) {
    		hash.put(a.getName(),a);
    	}
    }

    public static Map<String, Object> perform(String name, Map<String, Object> input) {
        Action a;
        synchronized (hash) {
        	a = hash.get(name);
        }
        if (a == null) return null;
        return a.perform(input);
    }
}